//#define __DEBUG__
// by Xeno
#define THIS_FILE "x_m3.sqf"
#include "x_setup.sqf"
private ["_vehicle", "_poss"];

_mpos = markerPos QGVAR(sm_503);
_mpos set [2,0];
_mpos1 = markerPos QGVAR(sm_503_1);
_mpos1 set [2,0];
_mpos2 = markerPos QGVAR(sm_503_2);
_mpos2 set [2,0];
GVAR(x_sm_pos) = [_mpos, _mpos1, _mpos2]; //  steal tank prototype, Ochrolimni, array 2 and 3 = infantry and armor positions
GVAR(x_sm_type) = "normal"; // "convoy"

#ifdef __SMMISSIONS_MARKER__
if (true) exitWith {};
#endif

if (X_Client && {!GVAR(IS_HC_CLIENT)}) then {
#ifndef __TT__
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_5031");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_5032");
#else
	GVAR(cur_sm_txt) = (localize "STR_DOM_SIDESTRING_5033");
	GVAR(current_mission_resolved_text) = (localize "STR_DOM_SIDESTRING_5034");
#endif
};

if (call FUNC(checkSHC)) then {
	__PossAndOther
	_pos_other2 = GVAR(x_sm_pos) select 2;
	_vehicle = objNull;
	_vehicle = createVehicle [GVAR(sm_tank), _poss, [], 0, "NONE"];
	_vehicle setDir  markerDir QGVAR(sm_503);
	_vehicle setPos _poss;
#ifndef __TT__
	sleep 2.123;
	["specops", 2, "basic", 4, _pos_other,250,true] spawn FUNC(CreateInf);
	sleep 2.321;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other2,1,400,true] spawn FUNC(CreateArmor);
	[_vehicle] spawn FUNC(sidesteal);
	_vehicle addMPEventHandler ["MPKilled", {if (isServer) then {[_this select 0, _this select 1, 2] call FUNC(sidempkilled)}}];
	_vehicle setDamage 0;
#else
	_vehicle addEventHandler ["killed", {_this call FUNC(KilledSMTargetNormal)}];
	_vehicle lock true;
	__AddToExtraVec(_vehicle)
	sleep 2.123;
	["specops", 2, "basic", 4, _pos_other,250,true] spawn FUNC(CreateInf);
	sleep 2.321;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other2,2,400,true] spawn FUNC(CreateArmor);
#endif
};
